"""
检查滑动窗口的实际批次数量
"""
from config import Config
from data_loader import DataLoader

def check_batch_count():
    """检查滑动窗口的实际批次数量"""
    config = Config()
    
    print("=== 检查滑动窗口批次数量 ===")
    print(f"当前配置:")
    print(f"  批次大小: {config.BATCH_SIZE}")
    print(f"  序列长度: {config.SEQ_LEN}")
    print(f"  滑动步长: {getattr(config, 'SLIDING_STEP', 5)}")
    print(f"  总文件数: {config.TOTAL_DATA}")
    
    # 创建数据加载器
    data_loader = DataLoader(config, sliding_step=getattr(config, 'SLIDING_STEP', 5))
    
    # 打印详细信息
    data_loader.print_sliding_info()
    
    # 计算实际可用的批次数
    max_batches = data_loader.get_max_batches()
    total_sequences = data_loader.get_total_sequences()
    
    print(f"\n=== 批次分配建议 ===")
    print(f"总可用批次数: {max_batches}")
    
    # 建议不同的训练/测试分割
    test_ratios = [0.1, 0.2, 0.3]
    
    for ratio in test_ratios:
        test_batches = max(1, int(max_batches * ratio))
        train_batches = max_batches - test_batches
        
        print(f"\n测试比例 {ratio*100:.0f}%:")
        print(f"  训练批次: {train_batches}")
        print(f"  测试批次: {test_batches}")
        print(f"  训练样本数: {train_batches * config.BATCH_SIZE}")
        print(f"  测试样本数: {test_batches * config.BATCH_SIZE}")
    
    # 推荐配置
    recommended_test_batches = max(2, int(max_batches * 0.2))  # 20%用于测试
    recommended_train_batches = max_batches - recommended_test_batches
    
    print(f"\n=== 推荐配置 ===")
    print(f"MAX_TRAIN_BATCHES = {recommended_train_batches}")
    print(f"TEST_BATCHES = {recommended_test_batches}")
    print(f"总训练样本数: {recommended_train_batches * config.BATCH_SIZE}")
    print(f"总测试样本数: {recommended_test_batches * config.BATCH_SIZE}")
    
    return max_batches, recommended_train_batches, recommended_test_batches

if __name__ == "__main__":
    max_batches, train_batches, test_batches = check_batch_count() 